package com.duobaoyu.dby.supply.biz.strategy.prewarning;

import com.duobaoyu.dby.channel.adapter.enums.biz.config.PreWarningConfigTypeEnum;
import com.duobaoyu.dby.supply.biz.strategy.AbstractPreWarningCountStrategy;
import com.duobaoyu.dby.supply.common.biz.dto.config.PreWarningConditionDTO;
import com.duobaoyu.dby.supply.common.biz.dto.order.OrderPageDTO;
import com.duobaoyu.dby.supply.db.repository.order.OrderRepository;
import com.google.common.collect.Sets;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Set;

/**
 * 订单预警数量统计
 * @author chenms
 * @date 2023/8/16 3:08 PM
 */
@Component
@Slf4j
@RequiredArgsConstructor
public class OrderPreWarningCountStrategy extends AbstractPreWarningCountStrategy {

    private final OrderRepository orderRepository;

    @Override
    protected long count(PreWarningConditionDTO preWarningCondition) {
        OrderPageDTO orderPage = new OrderPageDTO();
        orderPage.setPreWarningCondition(preWarningCondition);
        return orderRepository.queryOrderPageCount(orderPage);
    }

    @Override
    protected Set<Integer> supportPreWarningTypes() {
        return Sets.newHashSet(
                PreWarningConfigTypeEnum.ORDER_PAYMENT_NOT_SHIPPED.getValue(),
                PreWarningConfigTypeEnum.DELIVERY_NOT_COMPLETED.getValue(),
                PreWarningConfigTypeEnum.LOGISTICS_EXCEPTION.getValue(),
                PreWarningConfigTypeEnum.MANUAL_HANDLING.getValue()
                );
    }

}
